﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using FileSystem.Models;
/// <summary>
/// 
/// </summary>
namespace FileSystem.Services.IServices {
    /// <summary>
    /// 根目录项存储接口
    /// </summary>
    public interface IRootDirItemStorage {
        /// <summary>
        /// 初始化根目录项存储
        /// </summary>
        Task InitializeAsync();

        /// <summary>
        /// 根目录项存储是否已经初始化
        /// </summary>
        bool IsInitialized();

        /// <summary>
        /// 增加根目录项
        /// </summary>
        /// <param name="rootDirItem">要添加的根目录项</param>
        Task AddAsync(RootDirItem rootDirItem);

        /// <summary>
        /// 删除根目录项
        /// </summary>
        /// <param name="rootDirItem">要删除的根目录项</param>
        Task RemoveAsync(RootDirItem rootDirItem);

        /// <summary>
        /// 修改根目录项的属性
        /// </summary>
        /// <param name="rootDirItem">被修改的根目录项</param>
        /// <param name="property">要修改的属性</param>
        /// <param name="newContent">新值</param>
        Task ModifyProperty(RootDirItem rootDirItem, RootDirItemConst.Property property, string newContent);
        
        /// <summary>
        /// 根据用户名获得一个根目录项
        /// </summary>
        /// <param name="userName">用户名</param>
        Task<RootDirItem> GetRootDirItemAsync(string userName);

        /// <summary>
        /// 获得所有的根目录项
        /// </summary>
        Task<IList<RootDirItem>> GetRootDirItemsAsync();

        /// <summary>
        /// 判断根目录项是否存在
        /// </summary>
        /// <param name="userName">用户名</param>
        Task<bool> Exist(string userName);
    }

    /// <summary>
    /// 根目录项存储常量
    /// </summary>
    public static class RootDirItemStorageConstants {
        /// <summary>
        /// 默认的根目录项数据库版本号。
        /// </summary>
        public const int DefaultVersion = 0;

        /// <summary>
        /// 根目录项数据库版本号。
        /// </summary>
        public const int Version = 1;

        /// <summary>
        /// 根目录项数据库版本号键。
        /// </summary>
        public const string VersionKey = nameof(RootDirItemStorageConstants) +
            "." + nameof(Version);
    }
}